﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DTO;

namespace DAO
{

	public class KY_NANG_MEMDAO:IData<KY_NANG_MEM> 
 	{
		public KY_NANG_MEMDAO(String myconnecString) : base(myconnecString) { }

		protected override int InsertOnSubmit(ref KY_NANG_MEM item, int t) {
			 return connec.ExecuteNonQuery("sp_KY_NANG_MEM", CommandType.StoredProcedure,new SqlParameter("@flag", t),
				 new SqlParameter("@" + KY_NANG_MEM.c_ID, item.ID), new SqlParameter("@" + KY_NANG_MEM.c_TENKN_MEM, item.TENKN_MEM),
				 new SqlParameter("@" + KY_NANG_MEM.c_MOTA, item.MOTA));
		}

		public override KY_NANG_MEM GetItem(IDataReader dr)
		{
			KY_NANG_MEM obj = new KY_NANG_MEM();
			obj.ID = Convert.ToInt64(dr[KY_NANG_MEM.c_ID]);
			obj.TENKN_MEM = Convert.ToString(dr[KY_NANG_MEM.c_TENKN_MEM]);
			obj.MOTA = Convert.ToString(dr[KY_NANG_MEM.c_MOTA]);
			return obj;
		}

		public override List<KY_NANG_MEM> GetAll()
		{
			return GetAll("sp_GetAllKY_NANG_MEM", CommandType.StoredProcedure);
		}

		public override KY_NANG_MEM GetItemById(object id)
		{
			return GetAll().SingleOrDefault(p => p.ID == Convert.ToInt64(id));
		}
		public override KY_NANG_MEM GetItemById(KY_NANG_MEM item){
			throw new NotImplementedException();
		}

	}

 }
